package com.test.p08composite.example01;

import java.util.ArrayList;
import java.util.List;

public interface AbstractFile {

    void  killVirus();

}

class ImageFile implements  AbstractFile{

    private String name;

    public ImageFile(String name) {
        this.name = name;
    }

    @Override
    public void killVirus() {
        System.out.println("image file:"+ name +" scan ");
    }
}

class TextFile implements  AbstractFile{

    private String name;

    public TextFile(String name) {
        this.name = name;
    }

    @Override
    public void killVirus() {
        System.out.println("text file:"+ name +" scan ");
    }
}



class VidioFile implements  AbstractFile{

    private String name;

    public VidioFile(String name) {
        this.name = name;
    }

    @Override
    public void killVirus() {
        System.out.println("vidio file:"+ name +" scan ");
    }
}



 class Folder implements AbstractFile{

    private String name;

    private List<AbstractFile> lists = new ArrayList<AbstractFile>();


     public Folder(String name) {
         super();
         this.name = name;
     }

     public void add(AbstractFile file){
         lists.add(file);
     }

     public void remove(AbstractFile file){
         lists.remove(file);
     }


     public AbstractFile getChild(int index){
         return lists.get(index);
     }
     @Override
     public void killVirus() {
         System.out.println("floder file");
         for(AbstractFile file:lists){
             file.killVirus();
         }
     }
 }